package com.zy.vo;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ResultVo {
    private int code;//响应状态 1000成功 2000失败
    private String msg;//响应消息
    private  Object result;//返回数据
    //成功
    public static ResultVo success(String msg){
        ResultVo resultVo=new ResultVo();
        resultVo.setMsg(msg);
        resultVo.setCode(1000);
        return  resultVo;
    }
    //返回数据
    public static ResultVo success(Object result){
        ResultVo resultVo=new ResultVo();
        resultVo.setResult(result);
        resultVo.setCode(1000);
        return  resultVo;
    }
    //失败
    public static ResultVo fail(String msg){
        ResultVo resultVo=new ResultVo();
        resultVo.setMsg(msg);
        resultVo.setCode(2000);

        return  resultVo;
    }
    //失败
   public static ResultVo fail(String msg, Exception e){
       ResultVo resultVo=new ResultVo();
       resultVo.setMsg(msg);
       resultVo.setCode(2000);
        log.info(msg,e);
       return  resultVo;
   }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }
}
